package com.jishaokang.util;

import com.jishaokang.dao.ConstDAO;
import com.jishaokang.dao.MessageDAO;
import com.jishaokang.model.dto.Message;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Created by NANA_Final on 2019/7/1.
 */
@Component
public class MaskWordUtil {

    @Autowired
    private ConstDAO constDAO;

    public boolean containMaskWord(String content){
        String maskWord = constDAO.select("maskWord").getConstValue();
        System.out.println("****"+maskWord);
        String regex = "(.*?);";
        String items = null;
        Matcher matcher = Pattern.compile(regex).matcher(maskWord);
        while (matcher.find()) {
            items = matcher.group(1);
            System.out.println(items);
            System.out.println(content.contains(items));
            System.out.println(content.indexOf(items));
            if (content.contains(items)) return true;
        }
        return false;
    }

}
